﻿using KLS.PPDS.Core.Entity;
using KLS.PPDS.Data.Database.Common;
using KLS.PPDS.Data.Database.Repository.RepositoryInterfaces;

namespace KLS.PPDS.Data.Database.Repository.EntityRepository
{
    public class LanguageRepository: LinqRepository<Language>, ILanguageRepository 
    {
        public Language GetByCode(string code)
        {
            var session = NHibernateSessionManager.Instance.GetSession();
            string query = string.Format(@"from Language l where l.Code=:code         
                               "
                           );
            var obj = session.CreateQuery(query).SetParameter("code", code).UniqueResult();
            if(obj!=null)
                return (Language) obj;
            return null;

        }
    }
}
